import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 自动注册vant组件
import Components from "unplugin-vue-components/vite";
import { VantResolver } from "unplugin-vue-components/resolvers";
// import {Components} from "unplugin-vue-components";
// import { VantResolver } from "unplugin-vue-components/resolvers";

import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import path from 'path';
import { viteMockServe } from "vite-plugin-mock";
import { createHtmlPlugin } from "vite-plugin-html";
// https://vite.dev/config/
export default defineConfig({
  server:{
   port:80,
   host:true
  },
  plugins: [
    createHtmlPlugin(),
    vue(),
    viteMockServe({
      //在哪个文件夹下编写模拟接口代码
      mockPath:'./src/mock',
      //在开发环境开启mock
      localEnabled:true
    }),
    Components({
      // dts:false, //解决组件类型定义文件的重复问题
      resolvers:[VantResolver({importStyle:false})] //解决组件样式重复加载问题
    }),
    createSvgIconsPlugin({
      // 指定需要缓存的图标文件夹
      iconDirs: [path.resolve(process.cwd(), 'src/icons')],

    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
